#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <set>
#define ll long long
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
bool _stmer;

const int N = 1e5 + 5, M = 2e5 + 5;

namespace G {

array <int, N> fir;
array <int, M> nex, to;

int cnt = 1;
void add(int x, int y) {
	cnt++;
	nex[cnt] = fir[x];
	to[cnt] = y;
	fir[x] = cnt;
}

} //namespace G

array <int, N> deg;
array <int, N> s, fa;

bool flg = 0;

int dfs(int x) {
	ll maxn = 0, sum = 0;
	if (deg[x] == 1) maxn = s[x], sum = maxn;
	for (int i = G::fir[x]; i; i = G::nex[i]) {
		if (G::to[i] == fa[x]) continue;
		fa[G::to[i]] = x;
		int res = dfs(G::to[i]);
		sum += res;
		if (res > maxn) maxn = res;
	}
	ll ans = 2ll * s[x] - sum;
	if (s[x] > sum) return flg = 1, 0;
	if (ans < 0) return flg = 1, 0;
	flg |= maxn - ans > sum - maxn;
	flg |= sum - maxn < s[x] - ans;
	return ans;
}

void solve() {
	deg.fill(0), fa.fill(0), G::cnt = 1, G::fir.fill(0);
	int n = read();
	for (int i = 1; i <= n; i++) s[i] = read();
	for (int i = 2; i <= n; i++) {
		int x = read(), y = read();
		G::add(x, y), G::add(y, x);
		deg[x]++, deg[y]++;
	}
	if (n == 2 && s[1] == s[2]) return (void)puts("YES");
	if (n == 1) return (void)puts("YES");
	if (n == 2) return (void)puts("NO");
	int rt = -1; flg = 0;
	for (int i = 1; i <= n; i++)
		if (deg[i] > 1) rt = i;
	flg |= (bool)dfs(rt);
	if (!flg) puts("YES");
	else puts("NO");
}

bool _edmer;
int main() {
	cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
	freopen("clean.in", "r", stdin);
	freopen("clean.out", "w", stdout);
#endif
	int T = read();
	while (T--) solve();
	return 0;
}
